//配置路由
import 'package:calculator/index.dart';
import 'package:calculator/view/H5View.dart';
import 'package:flutter/material.dart';

final routes = {
  '/':(context)=>IndexPage(),
  '/h5/view':(context,{arguments})=>H5View(arguments:arguments),
};

//固定写法
var onGenerateRoute = (RouteSettings settings) {
  // 统一处理
  final String name = settings.name;
  final Function pageContentBuilder = routes[name];
  if (pageContentBuilder != null) {
    if (settings.arguments != null) {
      final Route route = MaterialPageRoute(
          builder: (context) =>
              pageContentBuilder(context, arguments: settings.arguments));
      return route;
    } else {
      final Route route =
          MaterialPageRoute(builder: (context) => pageContentBuilder(context));
      return route;
    }
  }
};
